export class RailsCanvasMgr {
    private canvas: HTMLCanvasElement;
    private ctx: CanvasRenderingContext2D;
    constructor(canvas: HTMLCanvasElement) {
        this.canvas = canvas;
        this.ctx = this.canvas.getContext("2d")!;
    }

    public beginPath() {
        this.ctx.beginPath();
    };
    public finishPath() {
        this.ctx.stroke();
    }
    public moveToPoint(point: { x: number, y: number }) {
        this.ctx.moveTo(point.x, point.y);
    }
    public lineToPoint(point: { x: number, y: number }) {
        this.ctx.lineTo(point.x, point.y);
    }
    public drawCircle(center: { x: number, y: number }, radius: number, configs: { fillColor?: string }) {
        this.ctx.beginPath();
        this.ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI);
        this.ctx.fillStyle = configs.fillColor || "#00ff00";//设置填充颜色
        this.ctx.fill();//开始填充
        this.ctx.stroke();
    }
}